Skip to content

Feat: Demo changes for FullSend Skill Testing - #370

Open
Sushant2504 wants to merge 6 commits into
openshift:masterfrom
Sushant2504:ROSAENG-62419-test-PR
Open

Feat: Demo changes for FullSend Skill Testing#370
Sushant2504 wants to merge 6 commits into
openshift:masterfrom
Sushant2504:ROSAENG-62419-test-PR

Conversation

@Sushant2504

Copy link
Copy Markdown
Contributor

Summary

This PR adds utility functions for Kubernetes namespace validation and classification, along with enhanced logging in the OCMAgent controller for better observability. These changes demonstrate typical code quality improvements and feature additions for PR review tool testing.

Changes

New Utilities (pkg/util/namespace/)

  • ValidateNamespace() - Validates namespace names against Kubernetes naming conventions:
    • Max 63 characters
    • Lowercase alphanumeric and hyphens only
    • Cannot start or end with hyphen
    • Returns descriptive errors for validation failures
  • IsSystemNamespace() - Identifies system namespaces:
    • Detects core Kubernetes namespaces (kube-system, kube-public, kube-node-lease, default)
    • Detects OpenShift system namespaces (openshift-* prefix)
    • Useful for filtering or special handling of system resources

Test Coverage

  • Comprehensive Ginkgo/Gomega test suite with 17 test cases
  • Tests cover valid/invalid namespace scenarios
  • Tests for system namespace detection (Kubernetes and OpenShift)
  • Edge cases: empty names, length limits, special characters, hyphen positions

Controller Improvements (controllers/ocmagent/)

  • Added debug logging when OCMAgent resource not found
  • Enhanced error logging with namespace/name context
  • Added structured logging after successful resource retrieval (replicas, fleetMode)
  • Improves troubleshooting and observability

Test Results

✅ All 17 tests passing
✅ go build successful
✅ go mod tidy clean

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Enhancement (improves existing functionality)
  • Test coverage improvement

Checklist

  • Code follows project style guidelines
  • Ginkgo BDD test style used consistently
  • Functions properly documented
  • Tests cover success and failure paths
  • No RBAC wildcards introduced
  • Logging follows structured logging patterns

@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Advanced

Run ID: 9b65ceea-57fa-40f1-a62d-f73becb80a3d


Comment @coderabbitai help to get the list of available commands.

@openshift-ci
openshift-ci Bot requested review from Tafhim and chamalabey September 9, 2026 04:54
@openshift-ci

openshift-ci Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Sushant2504
Once this PR has been reviewed and has the lgtm label, please assign charlesgong for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@Sushant2504

Copy link
Copy Markdown
Contributor Author

/test ci/prow/coverage
/test ci/prow/lint
/test ci/prow/test
/test ci/prow/validate

@Sushant2504

Copy link
Copy Markdown
Contributor Author

/test all

@samanthajayasinghe

Copy link
Copy Markdown
Contributor

/fs-review

@fullsend-ai-review

fullsend-ai-review Bot commented Sep 9, 2026

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 6:18 AM UTC · Completed 6:32 AM UTC

Commit: bafddca · View workflow run →

Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $3.08

@fullsend-ai-review fullsend-ai-review Bot added the risk/moderate PR risk: moderate label Sep 9, 2026
@fullsend-ai-review

fullsend-ai-review Bot commented Sep 9, 2026

Copy link
Copy Markdown

Risk Assessment: moderate (2/5)

Details

PR expanded from 1 to 21 files with large blast radius driving change-size up, but all other signals are benign: no security-sensitive or CI changes, no dependency updates, uniformly low git churn and contention (Tier 2=1.0), and additive nature of changes; weighted composite rounds to 2, maintaining moderate level but for qualitatively different reasons than the prior single-file assessment.

Previous run

Risk Assessment: moderate (2/5)

Details

Low-risk change: a single new test file (119 lines) with no protected paths, no security-sensitive files, no dependency or CI changes, and a 100% test file ratio; moderate baseline for new file with no git history.

@fullsend-ai-review

fullsend-ai-review Bot commented Sep 9, 2026

Copy link
Copy Markdown

Review

Findings

Medium

  • [speculative-code] pkg/util/namespace/namespace.go:19ValidateNamespace() and IsSystemNamespace() are defined and tested but have zero callers anywhere in the codebase. CLAUDE.md explicitly prohibits speculative additions: "Don't add features for future use" and "Avoid speculative changes." These functions add code and test surface without providing value to the operator.
    Remediation: Remove both functions and their tests. Reintroduce in a future PR when a caller exists.

  • [network-policy-scope] pkg/ocmagenthandler/ocmagenthandler_networkpolicy.go:128 — The new Prometheus NetworkPolicy allows ingress from Prometheus pods to all ports on OCM Agent pods. The NamespacePrometheus doc comment states the purpose is metrics scraping on port 8383, but the NetworkPolicyIngressRule has no Ports restriction. This follows the existing pattern for all other NetworkPolicies in this file but incrementally widens attack surface.
    Remediation: Add a Ports field to the NetworkPolicyIngressRule restricting ingress to port 8383 (OCMAgentMetricsPort).

  • [scope-exceeded] — This PR bundles multiple distinct features, most of which duplicate changes already merged to master through PRs Feat: add coderabbit-review skill for fullsend reviews (ROSAENG-62419) #364, fix: Add NetworkPolicy to allow Prometheus metrics scraping on port 8383 #366, Add new OCM severity values (Important/Moderate/Low) as CRD enum superset #368, and Fix: Addition of configuration of code-review through fullsend #372. The .fullsend/ files, Prometheus NetworkPolicy constants, and severity enum extensions all exist on the current master branch. The PR branch appears to have diverged before those PRs were merged, making the diff misleadingly large (21 files). The net-new changes (namespace utilities, controller debug logging) should be submitted as separate, focused PRs.

Low

  • [missing-authorization] — No issue is linked to this PR. The branch name references ROSAENG-62419, which was used for the previously merged PR Feat: add coderabbit-review skill for fullsend reviews (ROSAENG-62419) #364. Net-new changes (namespace utilities, controller logging) lack traceability to authorized work.

  • [scope-creep] controllers/ocmagent/ocmagent_controller.go:77 — The V(2) debug logging additions are orthogonal to the other changes in this PR. The logging itself is correct (uses structured key-value pairs and appropriate levels), but it should be tracked separately.

  • [code-organization] pkg/util/namespace/namespace_test.go:10 — The Ginkgo test bootstrap (TestNamespace + RunSpecs) is inlined in the spec file. The repo convention places this in a separate *_suite_test.go file.
    Remediation: Extract to pkg/util/namespace/namespace_suite_test.go.

  • [logic-error] pkg/util/namespace/namespace.go:20ValidateNamespace does not enforce that the first character is alphabetic. While Kubernetes relaxes RFC 1123 to allow leading digits in namespace names, the function's documentation claims to follow "Kubernetes naming conventions" without noting this edge case. The function is currently unused, limiting impact.

  • [shell-injection] .fullsend/skills/coderabbit-review/scripts/run-coderabbit.sh:46 — The $PR variable is interpolated into gh api URL paths without numeric validation. Mitigated by the sandbox environment and gh CLI URL encoding.
    Remediation: Add validation: [[ "$PR" =~ ^[0-9]+$ ]] || die "PR_NUMBER must be numeric".

  • [argument-injection] .fullsend/skills/coderabbit-review/scripts/run-coderabbit.sh:88 — GitHub API response bodies (containing untrusted comment text) are passed as CLI arguments to node -e. For PRs with many comments, this could exceed ARG_MAX.
    Remediation: Pipe JSON through stdin instead of command-line arguments.

  • [redundant-change] — The majority of this PR's diff (estimated 17 of 21 files) duplicates changes already present on master. Rebasing on current master would eliminate the redundant diffs and clarify the actual scope of net-new work.

  • [deprecation-contract] api/v1alpha1/managednotification_types.go:31 — Deprecation of SeverityWarning, SeverityInfo, and SeverityMajor is communicated only via Go source comments. YAML consumers creating CRs have no visibility into the deprecation.


Next steps:

  • /fs-fix — agent addresses review findings automatically
  • /fs-fix <your instruction> — agent fixes with your specific guidance
  • Push commits directly — review re-runs automatically on push
  • /fs-fix-stop — disable automatic fix runs for this PR
Previous run

Review

Findings

Critical

  • [logic-error] pkg/util/namespace/namespace_test.go:20 — The test file calls ValidateNamespace() and IsSystemNamespace() but neither function exists in the namespace package. The only function in pkg/util/namespace/namespace.go is GetOperatorNamespace(). This package will fail to compile. The PR body claims "✅ All 17 tests passing" and "✅ go build successful", but these claims are false — go build and go test will both fail with undefined function errors.
    Remediation: Either (1) add the implementations of ValidateNamespace and IsSystemNamespace to pkg/util/namespace/namespace.go in this PR, or (2) remove these tests until the functions are implemented.

  • [scope-exceeded] pkg/util/namespace/namespace_test.go — The PR description claims multiple categories of changes (new utility functions ValidateNamespace/IsSystemNamespace, controller improvements with enhanced logging in controllers/ocmagent/) but the actual diff contains only one new test file. The functions under test do not exist anywhere in the codebase. The PR body fabricates a scope that does not match the actual change.
    Remediation: Either include the claimed implementation code and controller changes, or rewrite the PR description to accurately reflect the actual diff content.

High

  • [missing-authorization] — No issue is linked in the PR body. The branch name references ROSAENG-62419, but that Jira ticket was already used for the previously merged PR Feat: add coderabbit-review skill for fullsend reviews (ROSAENG-62419) #364. Reusing a consumed ticket identifier does not constitute authorization for new work. The PR title ("Demo changes for FullSend Skill Testing") indicates this is a test/demo PR rather than authorized production work.
    Remediation: Link a dedicated, open Jira ticket that authorizes this specific change. If this is a demo/test PR not intended for merge, mark it as Draft.

Medium

  • [code-organization] pkg/util/namespace/namespace_test.go:10 — The codebase convention places the Ginkgo test bootstrap function (RegisterFailHandler + RunSpecs) in a dedicated *_suite_test.go file, separate from test specs. All 5 existing test packages follow this pattern. This file inlines the bootstrap into the spec file.
    Remediation: Extract the TestNamespace function (lines 10–13) into a new file namespace_suite_test.go.

Low

  • [naming-convention] pkg/util/namespace/namespace_test.go:12 — Suite description "Namespace Suite" follows the existing <Component> Suite pattern acceptably.

  • [pattern-inconsistency] pkg/util/namespace/namespace_test.go:6 — Uses ginkgo/v2 while existing test files use ginkgo v1. CLAUDE.md recommends v2 for new code, so this aligns with the stated migration direction.

  • [misplaced-abstraction] pkg/util/namespace/namespace_test.go — The existing pkg/util/namespace/ package is narrowly scoped to operator namespace retrieval via environment variable. Adding namespace validation and system namespace classification would significantly expand its responsibility. If these functions are to be added, evaluate whether they belong here or in a separate utility package.


Next steps:

  • /fs-fix — agent addresses review findings automatically
  • /fs-fix <your instruction> — agent fixes with your specific guidance
  • Push commits directly — review re-runs automatically on push
  • /fs-fix-stop — disable automatic fix runs for this PR

fullsend-ai-review[bot]

This comment was marked as outdated.

redhat-chai-bot and others added 5 commits September 9, 2026 12:46
The ocm-agent-operator creates a ServiceMonitor for Prometheus to scrape
port 8383 metrics, but the existing NetworkPolicies only allow
Alertmanager and MUO ingress. This causes TargetDown alerts because
prometheus-k8s pods from openshift-monitoring cannot reach the
ocm-agent metrics endpoint.

Add a new NetworkPolicy that allows prometheus-k8s pods (selected by
app.kubernetes.io/name=prometheus) from openshift-monitoring to reach
the ocm-agent. The policy is created in both fleet and non-fleet modes
since Prometheus scraping is needed in both.

Uses the existing dispatch-key pattern (like NamespaceRHOBS) so
NamespacePrometheus maps back to the real openshift-monitoring namespace
via callerNamespace().

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…rset

ROSAENG-62697: align ManagedNotification severity with OCM Service Log's new HCC-aligned labels
@Sushant2504

Copy link
Copy Markdown
Contributor Author

/fs-review

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.88889% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.07%. Comparing base (1c770c2) to head (5686c8b).
⚠️ Report is 7 commits behind head on master.

Files with missing lines Patch % Lines
controllers/ocmagent/ocmagent_controller.go 50.00% 3 Missing ⚠️
...g/ocmagenthandler/ocmagenthandler_networkpolicy.go 87.50% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #370      +/-   ##
==========================================
+ Coverage   65.39%   66.07%   +0.68%     
==========================================
  Files          23       23              
  Lines        1598     1636      +38     
==========================================
+ Hits         1045     1081      +36     
- Misses        473      475       +2     
  Partials       80       80              
Files with missing lines Coverage Δ
api/v1alpha1/managedfleetnotification_types.go 33.33% <ø> (ø)
api/v1alpha1/managednotification_types.go 84.61% <ø> (ø)
pkg/consts/ocmagenthandler/ocmagenthandler.go 100.00% <ø> (ø)
pkg/util/namespace/namespace.go 96.55% <100.00%> (+13.21%) ⬆️
...g/ocmagenthandler/ocmagenthandler_networkpolicy.go 78.57% <87.50%> (+1.64%) ⬆️
controllers/ocmagent/ocmagent_controller.go 38.18% <50.00%> (+2.18%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Sushant2504

Copy link
Copy Markdown
Contributor Author

/fs-review

1 similar comment
@Sushant2504

Copy link
Copy Markdown
Contributor Author

/fs-review

@openshift-ci

openshift-ci Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

@Sushant2504: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/lint 5686c8b link true /test lint
ci/prow/validate 5686c8b link true /test validate
ci/prow/osd-gcp-e2e 5686c8b link true /test osd-gcp-e2e

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@samanthajayasinghe

Copy link
Copy Markdown
Contributor

/fs-review

@fullsend-ai-review

fullsend-ai-review Bot commented Sep 9, 2026

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 11:08 PM UTC · Completed 11:29 PM UTC

Commit: 5686c8b · View workflow run →

Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $7.72

@fullsend-ai-review fullsend-ai-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the review comment for full details.

return ns, nil
}

// ValidateNamespace checks if a namespace name follows Kubernetes naming conventions

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[medium] speculative-code

ValidateNamespace() and IsSystemNamespace() are defined and tested but have zero callers anywhere in the codebase. CLAUDE.md explicitly prohibits speculative additions.

Suggested fix: Remove both functions and their tests. Reintroduce in a future PR when a caller exists.

var namespaces []string
if ocmAgent.Spec.FleetMode {
namespaces = append(namespaces, oah.NamespaceMonitorng, oah.NamespaceRHOBS, oah.NamespaceOBO)
namespaces = append(namespaces, oah.NamespaceMonitorng, oah.NamespaceRHOBS, oah.NamespaceOBO, oah.NamespacePrometheus)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[medium] network-policy-scope

The new Prometheus NetworkPolicy allows ingress from Prometheus pods to all ports on OCM Agent pods. The NamespacePrometheus doc comment states the purpose is metrics scraping on port 8383, but the NetworkPolicyIngressRule has no Ports restriction. This follows the existing pattern but incrementally widens attack surface.

Suggested fix: Add a Ports field to the NetworkPolicyIngressRule restricting ingress to port 8383 (OCMAgentMetricsPort).

// Request object not found, could have been deleted after reconcile request.
// Owned objects are automatically garbage collected. For additional cleanup logic use finalizers.
// Return and don't requeue
reqLogger.V(2).Info("OCMAgent resource not found, marking as absent")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[low] scope-creep

The V(2) debug logging additions are orthogonal to the other changes in this PR and should be tracked separately.

. "github.com/onsi/gomega"
)

func TestNamespace(t *testing.T) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[low] code-organization

The Ginkgo test bootstrap (TestNamespace + RunSpecs) is inlined in the spec file. The repo convention places this in a separate *_suite_test.go file.

Suggested fix: Extract to pkg/util/namespace/namespace_suite_test.go.

}

// ValidateNamespace checks if a namespace name follows Kubernetes naming conventions
func ValidateNamespace(ns string) error {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[low] logic-error

ValidateNamespace does not enforce that the first character is alphabetic. While Kubernetes relaxes RFC 1123 to allow leading digits, the function documentation claims to follow Kubernetes naming conventions without noting this edge case. The function is currently unused.

command -v node >/dev/null || { echo "warning: node not found" >&2; emit_empty; }

# Get current PR head commit to filter stale comments.
head_sha=$(gh api "repos/${REPO}/pulls/${PR}" --jq '.head.sha' 2>/dev/null || true)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[low] shell-injection

The $PR variable is interpolated into gh api URL paths without numeric validation. Mitigated by the sandbox environment and gh CLI URL encoding.

Suggested fix: Add validation: [[ "$PR" =~ ^[0-9]+$ ]] || die "PR_NUMBER must be numeric".

}));

console.log(JSON.stringify([...review, ...issue]));
" "$BOT" "$head_sha" "$review_raw" "$issue_raw"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[low] argument-injection

GitHub API response bodies containing untrusted comment text are passed as CLI arguments to node -e. For PRs with many comments, this could exceed ARG_MAX.

Suggested fix: Pipe JSON through stdin instead of command-line arguments.

SeverityWarning NotificationSeverity = "Warning"
SeverityInfo NotificationSeverity = "Info"
SeverityMajor NotificationSeverity = "Major"
SeverityWarning NotificationSeverity = "Warning" // Deprecated: use SeverityModerate

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[low] deprecation-contract

Deprecation of SeverityWarning, SeverityInfo, and SeverityMajor is communicated only via Go source comments. YAML consumers creating CRs have no visibility into the deprecation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk/moderate PR risk: moderate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants